package com.sgb.kjwl.viewmodel.vehicleManagement;

import androidx.databinding.ObservableField;

import com.sgb.kjwl.api.APIManager;
import com.swgk.core.view.entity.DriverAuthDetailEntity;
import com.sgb.kjwl.model.entity.transport.DriverVerifyEntity;
import com.sgb.kjwl.repository.HomeRepertory;
import com.sgb.kjwl.view.ui.activity.vehicleManagement.DriverCertificationAuditStatusActivity;
import com.swgk.core.base.BaseViewModel;
import com.swgk.core.base.model.entity.BaseEntity;
import com.swgk.core.dialog.DialogHelper;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

public class DriverCertificationAuditStatusAtvModel extends BaseViewModel {

    DriverCertificationAuditStatusActivity driverCertificationAuditStatusActivity;
    public ObservableField<DriverVerifyEntity> filterJson = new ObservableField<DriverVerifyEntity>(new DriverVerifyEntity());

    HomeRepertory repertory;

    public DriverCertificationAuditStatusAtvModel(DriverCertificationAuditStatusActivity driverCertificationAuditStatusActivity, HomeRepertory repertory) {
        this.driverCertificationAuditStatusActivity = driverCertificationAuditStatusActivity;
        this.repertory = repertory;
    }


    public void getDriverAuthDetail() {
        DialogHelper.showProgressDialog(driverCertificationAuditStatusActivity, null, "加载中", 0, true, null).setCanceledOnTouchOutside(false);

        APIManager.getInstance().getDriverAPI().driverAuthDetail().enqueue(new Callback<BaseEntity<DriverAuthDetailEntity>>() {
            @Override
            public void onResponse(Call<BaseEntity<DriverAuthDetailEntity>> call, Response<BaseEntity<DriverAuthDetailEntity>> response) {
                DialogHelper.dismissProgressDialog();
                if (response.body() == null || response.body().getState() == null)
                    return;
                driverCertificationAuditStatusActivity.showDetails(response.body().getData());
            }

            @Override
            public void onFailure(Call<BaseEntity<DriverAuthDetailEntity>> call, Throwable t) {
                DialogHelper.dismissProgressDialog();
            }
        });

    }
}
